package com.citybox.web.controller.user;

import com.citybox.domain.user.UserDo;
import com.citybox.infrastructure.user.persistence.service.UserService;
import com.citybox.shared.web.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhao.x
 */
@Tag(name = "用户信息")
@RestController
@RequestMapping(value = "/user")
@Slf4j
public class UserController {

    @Resource
    private UserService userService;

    @Operation(summary = "id查询用户信息")
    @GetMapping("/profile")
    public R<UserDo> getProfile(HttpServletRequest request) {
        String userId = request.getAttribute("userId").toString();
        return R.ok(userService.findById(userId));
    }

}
